package com.css.zfzx.sjcj.modules.hddcSamplePoint.repository;

import com.css.zfzx.sjcj.modules.hddcA1InvRgnHasMaterialTable.repository.entity.HddcA1InvrgnhasmaterialtableEntity;
import com.css.zfzx.sjcj.modules.hddcSamplePoint.repository.entity.HddcSamplepointEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author zhangcong
 * @date 2020-11-28
 */
public interface HddcSamplepointRepository extends JpaRepository<HddcSamplepointEntity, String> {
    @Modifying
    @Query(nativeQuery = true,value = "update hddc_samplepoint set qualityinspection_status=:qualityinspection_status ,extends1=:extend1 where uuid=:uuid")
    void updateStatus(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend1") String extend1,@Param("uuid") String uuid);

    @Query(nativeQuery = true,value = "select s.* from hddc_samplepoint s where s.id=?1 and s.is_valid=1")
    HddcSamplepointEntity findbyId(String samplepointid);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_samplepoint set qualityinspection_status=:s ,extends2=:str where uuid=:uuid")
    void updateStatus2(String s, String str, String uuid);

    @Query(nativeQuery = true,value = "select * from hddc_samplepoint where is_valid=1 and (qualityinspection_status!=3 or qualityinspection_status is null)")
    List<HddcSamplepointEntity> findByAll();

    HddcSamplepointEntity findBySamplesourceidAndIsValid(String id, String isValid);

    HddcSamplepointEntity findByUuidAndIsValid(String id, String isValid);
}
